

import requests


class HeaderUtil:
    @classmethod
    def get_token(cls):
        url='http://ihrm-test.itheima.net/api/sys/login'
        header={"Content-Type": "application/json"}
        body={"mobile": "13800000002","password": "123456"}
        resp=requests.post(url=url,headers=header,json=body)
        token=resp.json().get('data')
        return token
    @classmethod
    def get_departmentId(cls):
        url = 'http://ihrm-test.itheima.net/api/company/department'
        header = {"Content-Type": "application/json", "Authorization": HeaderUtil.get_token()}
        data={"name": "物资部","code": "1728"}
        resp = requests.post(url=url, headers=header, json=data)
        departmentId=resp.json().get('data').get('id')
        return departmentId
